string_contains

This function searches a string for a specific text and, if found, returns the position where the text starts.

int string_contains(string the_string, string the_search, int occurrence)

Parameters:
the_string
The string that will be searched.
the_search
The text to search for within the string.
occurrence
The occurrence of the text to return (starting at 1).

Return value:
The position in the source string where the search string was found on success, or -1 if there was an error or the text could not be found.

Remarks:
Please note that the position returned is 0 based.

The search is case sensitive, meaning that Name is different from name, for instance.

Example:
void main()
{
alert("string_contains test 1", "string_contains="+string_contains("Hello, I am a string!", "ring", 1)); //output should be 16.
alert("string_contains test 2", "string_contains="+string_contains("Hello, I will bring you a string!", "ring", 2)); //output should be 28.
alert("string_contains test 3", "string_contains="+string_contains("Hello, I am a string!", "Ring", 1)); //output should be -1, as Ring is different from ring.
}